<%@page import="com.liferay.portal.theme.ThemeDisplay"%>

<%@ page import="com.crossriver.crgis.cofo.util.ApplicationCofOConstants" %>
 
<%@ page import="com.crossriver.crgis.database.model.Application_C_of_O" %>
<%@page import="com.crossriver.crgis.database.model.Organisation_Information"%>
<%@page import="com.crossriver.crgis.database.model.Company_Contact_Person"%>
<%@page import="com.crossriver.crgis.database.model.History_Of_Information"%>
<%@page import="com.crossriver.crgis.database.model.Contact_Information"%>
<%@page import="com.crossriver.crgis.database.model.Property_Information"%>
<%@page import="com.crossriver.crgis.database.model.Supporting_Document"%>


<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ include file="/init.jsp"%>


<%

Application_C_of_O appl =
		(Application_C_of_O)request.getAttribute(
				ApplicationCofOConstants.APPL_C_OF_O_SESSION_ATTR);


Organisation_Information orgInfo = (Organisation_Information)
			request.getAttribute(
				ApplicationCofOConstants.ORGANISATION_INFO_SESSION_ATTR);

Company_Contact_Person coyContPerson = (Company_Contact_Person)
request.getAttribute(
	ApplicationCofOConstants.COY_CONTACT_SESSION_ATTR);


List<History_Of_Information> history = (List<History_Of_Information>)
					request.getAttribute(
						ApplicationCofOConstants.HISTORY_INFO_SESSION_ATTR);


Contact_Information indContInfo = (Contact_Information)
		request.getAttribute(
			ApplicationCofOConstants.IND_CONTACT_SESSION_ATTR);

Property_Information propInfo = (Property_Information)
			request.getAttribute(
				ApplicationCofOConstants.PROPERTY_INFO_SESSION_ATTR);


List<Supporting_Document> suppDocs = (List<Supporting_Document>)
			request.getAttribute(
				ApplicationCofOConstants.SUPP_DOC_INFO_SESSION_ATTR);
%>


<div id="main">
	<h1>Application Status</h1>
	<div class="content">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">

			<tr>
			<td colspan="2">
				<p>This is your Application Status page.</p>
				<%=appl.getStatus() %>
				<table width="100%" cellpadding="10px" cellspacing="0" style="font-size:12px" bgcolor="#FFFF62">
              		<tbody><tr>
              		<%
              		if(appl.getStatus().equalsIgnoreCase("SUBMITTED")){
              		%>
              		
	              	<td><img src="images/cnr-pending.png"></td>
	                  <td> Your application is currently <strong class="pending"><%=appl.getStatus() %>!</strong>.
	                  Please take note of your ID,<br><strong><%=appl.getReferenceNo() %></strong> while 
	                  your application is still being processed.
	                  </td>
	                 <%
              		}else if(appl.getStatus().equalsIgnoreCase("APPROVED")){
	                 %>
	                 <td><img src="images/success.png" width="30" height="30"></td>
	                 <td> Your application was successfull and has been <strong class="approved"><%=appl.getStatus() %>!</strong>.
                        Please take note of your Application ID, <strong><%=appl.getReferenceNo() %></strong>
                        </td>
	                 
	                 <%
              		}else if(appl.getStatus().equalsIgnoreCase("STOPPED")){
	                 %>
	                 <td><img src="images/failed.png"></td>
	                 <td> Your application has been <strong class="stopped"><%=appl.getStatus() %>!</strong>.
                        Please take note of your Application ID, <strong><%=appl.getReferenceNo() %></strong>. 
                        Contact us for further details.
                        </td>
	                 <%
              		}
	                 %>
	              </tr>
	              </tbody>
	           </table>
              <br>
              <p>Details of your application are detailed below.</p>
              <hr>
			</td>
			</tr>
		

			<tr>
			<td width="1%" valign="top">
				<aui:input name="applicationId" type="hidden" value="<%= appl.getApplicationId() %>"></aui:input>
				
			</td>
			<td width="99%" valign="top">
				<table width="100%" id="mainform">
					<tr>
						<td class="title" colspan="4">Application Summary</td>
					</tr>
					<tr>
						<td align="right" colspan="4">
						<hr>
						</td>
					</tr>
					
				<!-- Show this if this Re-CofO -->
				<%
				if (appl.getApplication().equalsIgnoreCase("RE-CERTIFICATION"))
				{
				%>
					<tr>
						<td colspan="4"><br>
							<liferay-portlet:actionURL var="editOldFileInfomation">
							  <liferay-portlet:param name="javax.portlet.action" value="editOldFileInfomation"></liferay-portlet:param>
							  <liferay-portlet:param name="applicationId" value="<%= appl.getApplicationId() %>">"></liferay-portlet:param>
							</liferay-portlet:actionURL>
							<span style="float: left; margin: 0; padding: 0" class="stitle">Old File Information</span> 
							<span style="float: right; margin: 0; padding: 0"><a href="<%= editOldFileInfomation %>"></a></span><br>
							<hr>
						</td>
					</tr>
					
					<tr>
						<td colspan="4">
							<span class="dtitle">Old Certificate of Occupancy Number</span> 
							<span class="data"><%= appl.getOldCofONo()%></span>
						</td>
					</tr>
					<tr>
						<td colspan="4">
							<span class="dtitle">File Number</span> 
							<span class="data"><%= appl.getFileNo()%></span>
						</td>
					</tr>
				
				<%
				}
				%>					 
					<tr>
						<td colspan="4"><br>
							<liferay-portlet:actionURL var="editOrganisationInformation">
							  <liferay-portlet:param name="javax.portlet.action" value="editOrganisationInformation"></liferay-portlet:param>
							  <liferay-portlet:param name="applicationId" value="<%= appl.getApplicationId() %>">"></liferay-portlet:param>
							</liferay-portlet:actionURL>
							<span style="float: left; margin: 0; padding: 0" class="stitle">Organisation Information</span> 
							<span style="float: right; margin: 0; padding: 0"><a href="<%= editOrganisationInformation %>"></a></span><br>
							<hr>
						</td>
					</tr>
					
					 
					<tr>
						<td colspan="2"><br>
							<span class="dtitle">Organisation Full Name</span> 
							<span class="data"> <%= orgInfo.getOrganisationName().toUpperCase() %></span>
						</td>
						<td colspan="2"><br>
							<span class="dtitle">Registration Number (RC)</span> 
							<span class="data"><%= orgInfo.getRegNo().toUpperCase() %></span>
						</td>
					</tr>
					<tr>
						<td colspan="2"><br>
							<span class="dtitle">Country of Registration</span>
							<span class="data"><%= orgInfo.getCountryOfReg().toUpperCase() %></span>
						</td>
						<td colspan="2"><br>
							<span class="dtitle">Date of Registration</span> 
							<span class="data"><%= orgInfo.getDateOfRegistration() %></span>
						</td>
					</tr>
					<tr>
						<td colspan="4"><br>
							<span class="dtitle">Nature of Business</span> 
							<span class="data"><%= orgInfo.getNatureOfBusiness().toUpperCase() %></span></td>
					</tr>
					<tr>
						<td colspan="4"><br>
							<span class="stitle">Organisation Contact Person</span> 
<%-- 							<span style="float: right; margin: 0; padding: 0"><a href="<%= editCompanyContactPerson %>"></a></span><br> --%>
							<hr>
						</td>
					</tr>
					<tr>
						<td colspan="2"><br><span class="dtitle">Designation: </span><span class="data"><%= coyContPerson.getDesignation() %></span></td>	
            <td colspan="2"><br><span class="dtitle">Title: </span><span class="data"><%= coyContPerson.getTitle() %></span></td>
	        </tr>
	        <tr>
						<td><br><span class="dtitle">Last Name: </span><span class="data"><%= coyContPerson.getLastName().toUpperCase() %></span></td>	
            <td><br><span class="dtitle">First Name: </span><span class="data"><%= coyContPerson.getFirstName().toUpperCase() %></span></td>
            <td><br><span class="dtitle">Middle Name:</span><span class="data"><%= coyContPerson.getMiddleName().toUpperCase() %></span></td>
            <td>&nbsp;</td>
	        </tr>
	        <tr>
						<td><br><span class="dtitle">Mobile Phone: </span><span class="data"><%= coyContPerson.getPhoneMobile() %></span></td>	
            <td><br><span class="dtitle">Office Phone: </span><span class="data"><%= coyContPerson.getPhoneHome() %></span></td>
            <td><br><span class="dtitle">Home Phone:</span><span class="data"><%= coyContPerson.getPhoneOffice() %></span></td>
            <td>&nbsp;</td>
	        </tr>
	        <tr>
						<td colspan="2"><br><span class="dtitle">Email Address:</span><span class="data"><%= coyContPerson.getEmailAddress() %></span></td>	
            <td><br><span class="dtitle">Fax: </span><span class="data"><%= coyContPerson.getFax() %></span></td>
	        </tr>
		      <tr>
						<td colspan="2"><br><span class="dtitle">Identification Document:</span><span class="data"><%= coyContPerson.getIdentificationDoc() %></span></td>	
            <td colspan="2"><br><span class="dtitle" >Identification Document Number: </span><span class="data"><%= coyContPerson.getIdentificationDocNo() %></span></td>
	        </tr>     	
	
							<liferay-portlet:actionURL var="editAddressInformation">
							  <liferay-portlet:param name="javax.portlet.action" value="editAddressInformation"></liferay-portlet:param>
							  <liferay-portlet:param name="applicationId" value="<%= appl.getApplicationId() %>">"></liferay-portlet:param>
							</liferay-portlet:actionURL>
							
					<tr>
						<td colspan="4"><br>
							<span style="float: left; margin: 0; padding: 0" class="stitle">Address Information</span> 
							<span style="float: right; margin: 0; padding: 0"><a href="<%= editAddressInformation %>"></a></span><br>
							<hr>
						</td>
					</tr>
					
					<tr>
						<td colspan="4"><br>
							<span class="dtitle">Contact Address</span> 
							<span class="data"> 
								<%= indContInfo.getHouseNo() %>,
								<%= indContInfo.getAddressLine1() %><br>
								<%= indContInfo.getAddressLine2() %>, 
							</span>
						</td>
					</tr>
					<tr>
						<td><br><span class="dtitle">City/Town</span> <span class="data"><%= indContInfo.getCity()%></span></td>
						<td><br><span class="dtitle">State</span> <span class="data"><%= indContInfo.getState() %></span></td>
						<td><br><span class="dtitle">Country</span> <span class="data"><%= indContInfo.getCountry() %></span></td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td colspan="4"><br><span class="dtitle">P.M.B Address</span> <span class="data"><%= indContInfo.getPoBox() %></span></td>
					</tr>
					
						<liferay-portlet:actionURL var="editContactInformation">
						  <liferay-portlet:param name="javax.portlet.action" value="editContactInformation"></liferay-portlet:param>
						  <liferay-portlet:param name="applicationId" value="<%= appl.getApplicationId() %>">"></liferay-portlet:param>
						</liferay-portlet:actionURL>
						
					<tr>
						<td colspan="4"><br>
							<span class="stitle">Contact Information</span> 
							<span style="float:right; margin: 0; padding: 0"><a href="<%= editContactInformation %>"></a></span>
							<hr>
						</td>
					</tr>
					<tr>
						<td><br><span class="dtitle">Mobile Phone</span><span class="data"><%= indContInfo.getPhoneMobile() %></span></td>
						<td><br><span class="dtitle">Office Phone</span><span class="data"><%= indContInfo.getPhoneOffice() %></span></td>
						<td><br><span class="dtitle">Home Phone</span><span class="data"><%= indContInfo.getPhoneHome() %></span></td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td colspan="4"><br><span>Email Address</span> <span class="data"><%= indContInfo.getEmailAddress() %></span></td>
					</tr>
					
					<liferay-portlet:actionURL var="editApplicationHistory">
					  <liferay-portlet:param name="javax.portlet.action" value="editApplicationHistory"></liferay-portlet:param>
					  <liferay-portlet:param name="applicationId" value="<%= appl.getApplicationId() %>"></liferay-portlet:param>
					</liferay-portlet:actionURL>
					
					<tr>
						<td colspan="4"><br>
							<span style="float: left; margin: 0; padding: 0" class="stitle">Application History</span> 
							<span style="float: right; margin: 0; padding: 0"><a href="<%= editApplicationHistory %>"></a></span><br>
							<hr>
						</td>
					</tr>
					
					<tr>
						<td colspan="4">
							<table id="tb" cellpadding="5">
								<tr class="tbtitle"><td>Application Number of Previous Application</td></tr>
								<%
								for (int i =0; i<history.size(); i++){
									History_Of_Information hist  = history.get(i);
								%>
								<tr>
									<td>
									<%= hist.getOldApplicationId()%>
									</td>
								</tr>
								
								<%
								}
								%>
							</table>
						</td>
					</tr>
					
						<liferay-portlet:actionURL var="editPropertyInformation">
						  <liferay-portlet:param name="javax.portlet.action" value="editPropertyInformation"></liferay-portlet:param>
						  <liferay-portlet:param name="applicationId" value="<%= appl.getApplicationId() %>">"></liferay-portlet:param>
						</liferay-portlet:actionURL>
					
					
					<tr>
						<td colspan="4"><br>
							<span class="stitle">Property Information</span> 
							<span style="float: right; margin: 0; padding: 0"><a href="<%= editPropertyInformation %>"></a></span><br>
						<hr>
						</td>
					</tr>
					<tr>
						<td colspan="4">
							<table id="tb" cellpadding="5">
								<tr class="tbtitle">
									<td>Land Use:</td>
									<td>Land Purpose:</td>
								</tr>
								<tr>
									<td><%= appl.getLandUseType() %></td>
									<td><%= appl.getLandUsePurpose()%></td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td colspan="2"><br><span class="dtitle">Property Type</span> <span class="data"> <%= propInfo.getPropertyType()%></span></td>
						<td><br><span class="dtitle">Land Area</span> <span class="data"><%= propInfo.getArea()%> <%= propInfo.getUom()%> </span></td>
						<td><br><span class="dtitle">Block No.</span> <span class="data"> <%= propInfo.getBlockNo()%> </span></td>
					</tr>
					<tr>
						<td colspan="2"><br><span class="dtitle">Land Location</span> <span class="data"><%= propInfo.getLandLocation()%></span></td>
						<td colspan="2"><br>
							<span class="dtitle">City/Town/Village</span> 
							<span class="data"><%= propInfo.getCity()%>, <%= propInfo.getState()%>, <%= propInfo.getCountry()%></span>
						</td>
					</tr>
					<tr>
						<td colspan="4"><br>
							<span class="dtitle"> 
								Please provide additional useful information that may assist the agency in processing your application.
							</span>
							<span class="data"><%= propInfo.getOtherUsefulInformation()%></span> 
						</td>
					</tr>
					<tr>
						<td colspan="4"><br>
							<span class="dtitle">What is the date on the Original Certifiate of Occupancy (CofO)?</span>
							<span class="data"><%= propInfo.getOrigCofODate()%></span>
						</td>
					</tr>
					<tr>
						<td colspan="4"><br>
							<span class="dtitle">Was the original allocation made to you?</span>
							<span class="data"><%= propInfo.getAllocationMadToYou()%></span>
							</td>
					</tr> 
					<tr>
						<td colspan="4"><br>
							<span class="dtitle">Do you have an assignment?</span>
							<span class="data"><%= propInfo.getAssignedToYou()%></span> 
						</td>
					</tr>
					<tr>
						<td colspan="2"><br>
							<span class="dtitle">Specify Required Land Use</span> 
							<span class="data"><%= appl.getLandUseType()%></span>
						</td>
						<td colspan="2"><br>
							<span class="dtitle">Specify Purpose</span> 
							<span class="data"> <%= appl.getLandUsePurpose()%></span></td>
					</tr>
					
							<liferay-portlet:actionURL var="editSupportingDoc">
							  <liferay-portlet:param name="javax.portlet.action" value="editSupportingDoc"></liferay-portlet:param>
							  <liferay-portlet:param name="applicationId" value="<%= appl.getApplicationId() %>"></liferay-portlet:param>
							</liferay-portlet:actionURL>
					
					<tr>
						<td colspan="4"><br>
							<span class="stitle">Uploads</span> 
							<span style="float: right; margin: 0; padding: 0"><a href="<%= editSupportingDoc %>"></a></span><br>
						<hr>
						</td>
					</tr>
					<tr>
						<td colspan="4"><span>Documents Uploaded</span></td>
					</tr>
					
					<tr>
						<td colspan="4">
							<table id="tb" cellpadding="5">
								<tr class="tbtitle">
									<td>Document Name</td>
									<td>File Name</td>
									<td>Document Type</td>
								</tr>
								<%
								for (int i = 0; i<suppDocs.size(); i++){
									Supporting_Document suppDoc = suppDocs.get(i);
								%>
								<tr>
									<td >
										<%= suppDoc.getDocumentName() %>
									</td>
									<td >
									 <%= suppDoc.getFileName() %>
										
									</td>
									<td >
									<%= suppDoc.getDocumentType() %>
									</td>
									
								</tr>
								
								<%
								}
								%>
							</table>
						</td>
					</tr>
					<tr>
					</tr>
					
				</table>
				</td>
			</tr>
		</table>
	</div>
</div>